﻿@{
    ViewBag.Title = "Manage Group - Project Management System";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
    Manage Group</h2>
<form action="" method="post" id="form" name="formGroup">
<input type="hidden" id="Action" name="Action" />
@*store current url*@
<input type="hidden" name="url" id="url" />
<ul class="shortcut-buttons-set">
    @{if (PMS.Utilities.Utility.RoleID == 3)
      {
        <li><a class="shortcut-button" href="@Url.Action("AddGroup", "Project")"><span>
            <img src="../../Content/images/icons/Button-Add-icon.png" alt="icon" /><br />
            Add</span></a></li>
        <li><a class="shortcut-button" href="#" onclick="if(DoAction('@Url.Action("EditGroup", "Project")')==-1)jAlert('Please Select One Item', 'Message');">
            <span>
                <img src="../../Content/images/icons/paper_content_pencil_48.png" alt="icon" /><br />
                Edit</span></a></li>
        <li><a class="shortcut-button" href="javascript:Action('Delete')"><span>
            <img src="../../Content/images/icons/Button-Close-icon.png" alt="icon" /><br />
            Delete</span></a></li>
        @*<li><a class="shortcut-button" href="javascript:Action('Confirm')"><span>
            <img src="../../Content/images/icons/Actions-dialog-ok-apply-icon.png" alt="icon" /><br />
            Confirm</span></a></li>*@
        
      }
    }
</ul>
<!-- End .shortcut-buttons-set -->
<div class="clear">
</div>
<!-- End .clear -->
<!-- Search -->
<input type="hidden" id="isSearch" name="isSearch" value="@ViewData["IsSearch"]" />
<div class="content-box" id="Search">
    <!-- Start Content Box -->
    <div class="content-box-header">
        <h3 id="toggleSearch">
            Search</h3>
        <div class="clear">
        </div>
    </div>
    <!-- End .content-box-header -->
    <div class="content-box-content">
        <fieldset>
            <p>
                <label class="width12 floatLeft">
                    Group Name:</label>
                <input type="text" id="txtGroupName" name="GroupName" class="width20 input-inline text-input medium-input" value="@ViewData["GroupName"]"/>
            </p>
            <div class="childCol">
                <p>
                    <label class="width12 floatLeft">
                        Project:</label>
                    @Html.DropDownList("ProjectID", (SelectList)ViewData["ProjectList"], new { @class = "width20 input-inline", onchange = "$('#Page').attr('value', 1);$('form').submit();" })
                </p>
                <p>
                    <label class="width12 floatLeft">
                        Semester:</label>
                    @Html.DropDownList("SemesterID", (SelectList)ViewData["SemesterList"], new { @class = "width20 input-inline", onchange = "$('#Page').attr('value', 1);$('form').submit();" })
                </p>
                <p>
                    <label class="width12 floatLeft">
                        Status:</label>
                    <select class="width20 input-inline" id="cmbStatus" name="Status" onchange="$('#Page').attr('value', 1);$('form').submit();">
                        <option value="--All--">--All--</option>
                        <option value="Draft">Draft</option>
                        <option value="Confirm">Confirm</option>
                    </select>
                </p>
            </div>
            <div class="childCol">
                <p>
                    <label class="width12 floatLeft">
                        Schedule:</label>
                    @Html.DropDownList("ScheduleID", (SelectList)ViewData["ScheduleList"], new { @class = "width20 input-inline", onchange = "$('#Page').attr('value', 1);$('form').submit();" })
                </p>
                <p>
                    <label class="width12 floatLeft">
                        Leader:</label>
                    @Html.DropDownList("UserID", (SelectList)ViewData["UserList"], new { @class = "width20 input-inline", onchange = "$('#Page').attr('value', 1);$('form').submit();" })
                </p>
            </div>
        </fieldset>
    </div>
</div>
<div class="content-box">
    <!-- Start Content Box -->
    <div class="content-box-header">
        <h3>
            Group List</h3>
        <div class="clear">
        </div>
    </div>
    <!-- End .content-box-header -->
    <div class="content-box-content">
        <div>
            <!-- This is the target div. id must match the href of this div's tab -->
            @{ if (TempData["Message"] != null)
               {
                <div class="notification attention png_bg">
                    <a href="#" class="close">
                        <img src="../../Content/images/icons/cross_grey_small.png" title="Close this notification"
                            alt="close" /></a>
                    <div>
                        @TempData["Message"].ToString()
                    </div>
                </div>
               }
            }
            @{ 
                var pageSize = int.Parse(ViewData[PMS.ENT.PageInfo.PageSize.ToString()].ToString());
                var pageNum = int.Parse(ViewData[PMS.ENT.PageInfo.PageNum.ToString()].ToString());
                var page = int.Parse(ViewData[PMS.ENT.PageInfo.Page.ToString()].ToString()); }
            <input type="hidden" name="joinScheduleID" id="JoinScheduleID" />
            <input type="hidden" value="@ViewData["OrderBy"]" name="orderBy" id="orderBy" />
            <input type="hidden" value="@ViewData["OrderDirection"]" name="orderDirection"
                id="orderDirection" />
            @{if (Model.Count <= 0)
              {
                <div class="RecordFound @("RecordFound" + @Model.Count)">
                    No Record Found</div>
              }
            }
            <table class="flexigird TableGrid">
                <thead>
                    <tr>
                        <th id="Selected">
                            <input class="check-all" type="checkbox" id="checkAll" />
                        </th>
                        <th id="GroupName">
                            Group Name
                        </th>
                        <th id="Owner">
                            Team Leader
                        </th>
                        <th id="Member">
                            Member
                        </th>
                        <th id="Status">
                            Status
                        </th>
                    </tr>
                </thead>
                @*<tfoot>
                    <tr>
                        <td colspan="6">
                            @{ Html.RenderPartial("Pagination", null, ViewData); }
                            <!-- End .pagination -->
                            <div class="clear">
                            </div>
                        </td>
                    </tr>
                </tfoot>*@
                <tbody>
                    @{ for (int i = 0; i < Model.Count; i++)
                       {
                           string groupname = @Model[i].GroupName;
                        <tr>
                            <td>
                                <input type="checkbox" id="GroupID" name="GroupID" value="@Model[i].GroupID"
                                        group="Selected" onclick="Uncheck('GroupID');" status="@Model[i].Status" project="@Model[i].ProjectID" schedule="@Model[i].ScheduleID" />
                            </td>
                            <td>
                                @Html.ActionLink(groupname, "ViewGroup", new { ID = Model[i].GroupID }, null)
                            </td>
                            <td>
                                @Model[i].Owner
                            </td>
                            <td>
                                @Model[i].Member
                            </td>
                            <td>
                                @Html.Encode(Model[i].Status)
                            </td>
                        </tr>
                       } 
                    }
                </tbody>
            </table>
            @{Html.RenderPartial("Pagination", null, ViewData); }
        </div>
        <!-- End #tab1 -->
    </div>
    <!-- End .content-box-content -->
</div>
<!-- End .content-box -->
</form>
<script language="javascript" type="text/javascript">
    $("#url").val(document.URL);
    $("#Group").addClass("current");
    $("#Project").addClass("current");
    $("#toggleSearch").click(function () {
        if ($("#isSearch").val() == 1) {
            $("#isSearch").val(0);
        }
        else {
            $("#isSearch").val(1);
        }
    });

     $('#txtGroupName').keydown(function(event) {
         if (event.keyCode == 13) {
            $('form').submit(); 
         }
     });
     var sstatus = @Html.Raw(Json.Encode(ViewData["Status"]));
    $("#cmbStatus").val(sstatus);

    var isSearch = @ViewData["IsSearch"];
    if (isSearch == '1') {
        $("#Search").removeClass('closed-box');
    }
    else {
        $("#Search").addClass('closed-box');
    }

    
  
</script>
